﻿using HlELock.Core;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;

namespace HlELock.Modules.Hotel.Agency.ViewModels
{
    public class TestCardWindowViewModel : BindableBase
    {
        public TestCardWindowViewModel()
        {
            SendCard();
        }

        private List<string> CardCodes { get; set; } = new List<string>();

        private string _descr;
        public string Descr
        {
            get { return _descr; }
            set { SetProperty(ref _descr, value); }
        }

        private int _total;
        /// <summary>
        /// 当前发卡数量
        /// </summary>
        public int Total
        {
            get { return _total; }
            set { SetProperty(ref _total, value); }
        }

        private void SendCard()
        {
            Descr = AppHelper.GetResourceString("QingJianKaPianFangDaoSheBeiShang");
            MyAppContext.Device.TestCard(cardCode =>
            {
                Total++;
                CardCodes.Add(cardCode);
                Descr = AppHelper.GetResourceString("ChengGong");
                SendCard();
            });
        }
    }
}
